<?php

class Supplier extends AppModel {
    var $name = 'Supplier';

    var $primaryKey = 'id';

    var $order = 'Supplier.code';

    var $belongsTo = array(
            'User' => array(
                'foreignKey' => 'collector_id',
                'fields' => array('name')
        ),
    );

    var $validate = array(
        'code' => array(
                'between' => array(
                    'rule' => array('between', 3, 3),
                    'required' => true,
                    'message' => 'Supplier code must have 3 characters.',
            ),
                'isUnique' => array(
                    'rule' => 'isUnique',
                    'message' => 'This brand name is already taken.',
            ),
        ),
        'name' => array(
                'notEmpty' => array(
                    'rule' => array('notEmpty'),
                    'message' => 'Supplier name is required.',
                    'required' => true,
            ),
                'isUnique' => array(
                    'rule' => 'isUnique',
                    'message' => 'This Supplier name is already taken.',
            ),
        ),
    );
}
?>
